﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IDomainService.cs" company="Microsoft">
//   Microsoft
// </copyright>
// <summary>
//   Interface to implement a Domain Service that adds a layer between
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MySemanticSearch.Service
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;

    using MySemanticSearch.Web.Model;

    /// <summary>
    /// Interface to implement a Domain Service that adds a layer between 
    /// </summary>
    public interface IDomainService
    {
        /// <summary>
        /// Queries the RIA service to get a collection of documents
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        void GetDocuments(
            Action<ObservableCollection<Document>, Exception> callback,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable);

        /// <summary>
        /// Queries the RIA service to get a collection of related documents
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="documentsSelectedItem">
        /// The documents selected item.
        /// </param>
        void GetRelatedDocuments(
            Action<ObservableCollection<Document>, Exception> callback,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            string documentsSelectedItem);

        /// <summary>
        /// Queries the RIA service to search for documents using a query string
        /// </summary>
        /// <param name="viewModelCallback">
        /// The view model callback.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="query">
        /// The query.
        /// </param>
        void GetSearchResults(
            Action<ObservableCollection<Document>, Exception> viewModelCallback,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            string query);

        /// <summary>
        /// Retrieves all used databases from the service
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="sqlInstance">
        /// The sql instance.
        /// </param>
        /// <param name="hasFileTable">
        /// The has file table.
        /// </param>
        void GetDatabaseNameList(
            Action<IEnumerable<string>, Exception> viewModelCallbackMethod, string sqlInstance, bool hasFileTable);

        /// <summary>
        /// Retrieves the list of FileTables for a particular database
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        void GetFileTableList(
            Action<IEnumerable<string>, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase);

        /// <summary>
        /// Retrieves a list of all search properties for a selected FileTable
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        void GetSearchProperties(
            Action<IEnumerable<string>, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable);

        /// <summary>
        /// Retrieves tags for the database
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="sliderTopMaxValue">
        /// The slider top max value.
        /// </param>
        void GetTags(
            Action<Dictionary<string, double>, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            int sliderTopMaxValue);

        /// <summary>
        /// Retrieves tags for a set of documents
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="selectedDocuments">
        /// The selected documents.
        /// </param>
        /// <param name="sliderTopMaxValue">
        /// The slider top max value.
        /// </param>
        void GetTagsForDocuments(
            Action<Dictionary<string, double>, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            List<string> selectedDocuments,
            int sliderTopMaxValue);

        /// <summary>
        /// Downloads a specific document from the RIA service
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="documentGuid">
        /// The document guid.
        /// </param>
        void DownloadDocument(
            Action<byte[], Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            string documentGuid);

        /// <summary>
        /// Deletes a specific document from the FileTable
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="documentGuid">
        /// The document guid.
        /// </param>
        void DeleteDocument(
            Action<bool, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            string documentGuid);

        /// <summary>
        /// Uploads a document to the FileTable
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="document">
        /// The document.
        /// </param>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        void UploadDocument(
            Action<bool, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            byte[] document,
            string fileName);

        /// <summary>
        /// Obtains a collection of documents that share a common tag
        /// </summary>
        /// <param name="viewModelCallbackMethod">
        /// The view model callback method.
        /// </param>
        /// <param name="selectedSqlInstance">
        /// The selected sql instance.
        /// </param>
        /// <param name="selectedDatabase">
        /// The selected database.
        /// </param>
        /// <param name="selectedFileTable">
        /// The selected file table.
        /// </param>
        /// <param name="tag">
        /// The tag param.
        /// </param>
        void GetDocumentsByTag(
            Action<ObservableCollection<Document>, Exception> viewModelCallbackMethod,
            string selectedSqlInstance,
            string selectedDatabase,
            string selectedFileTable,
            string tag);
    }
}
